package cn.hamster3.hamsterworld.command;

import cn.hamster3.hamsterworld.core.DataManager;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;

public class ListCommand extends CommandBase {
    public ListCommand(DataManager dataManager) {
        super(dataManager);
    }

    @Override
    public boolean isPlayerCommand() {
        return false;
    }

    @Override
    public String getPermission() {
        return "hw.admin";
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        sender.sendMessage("§a======================[ 世界列表 ]======================");
        for (World world : Bukkit.getWorlds()) {
            sender.sendMessage("§a世界: " + world.getName() + " 在线人数: " + world.getPlayers().size());
        }
        sender.sendMessage("§a======================[ 世界列表 ]======================");
        return true;
    }
}
